/**
 * 数据源  相当于组件中的data
 * @type {{state: {tabList: [], currentMenu: {}, menu: []}}}
 */
const state = {
  tabList: []
}

/**
 * 组件中的方法 methods
 * @type {{selectMenu(*, *=): void, closeTab(*, *): void}}
 */
const mutations = {
  selectMenu (state, val) {
        state.currentMenu = val
        if (state.tabList.length <=0)
        { 
           state.tabList.push(val) 
        }
        else {
            const result = state.tabList.findIndex(item => item.path === val.path)
            result === -1 ? state.tabList.push(val) : ''
        }
   
  },
  closeTab (state, val) {
    const result = state.tabList.findIndex(item => item.path === val.path)
    state.tabList.splice(result, 1)
  }
}

export default {
 
  state,
  mutations
}
